package com.ffcs.cn.action.desktopcontrol.smpanelsymbol;

import com.supermap.data.Resources;
import com.supermap.data.Symbol;
import com.supermap.desktop.controls.dialog.symbolDialogs.JpanelSymbols.SmPanelSymbolFill;
import com.supermap.desktop.controls.dialog.symbolDialogs.JpanelSymbols.SmPanelSymbolLine;
import com.supermap.desktop.controls.dialog.symbolDialogs.JpanelSymbols.SmPanelSymbolPoint;
import com.supermap.desktop.controls.ui.controls.SmDialog;
import com.supermap.desktop.core.Application;

import javax.swing.*;
import java.awt.*;

/**
 * 符号面板的示例对话框
 *
  */
public class DialogSmPanelSymbol extends SmDialog {
	private SmPanelSymbolPoint panelSymbolPoint;
	private SmPanelSymbolLine panelSymbolLine;
	private SmPanelSymbolFill panelSymbolFill;

	public DialogSmPanelSymbol() {
		setSize(new Dimension(300, 100));
		setTitle("符号面板");
		initComponents();
		initLayout();
	}

	private void initComponents() {
		// 当前工作空间存放符号库的对象
		Resources resources = Application.getActiveApplication().getWorkspace().getResources();
		try {
			Symbol symbolPoint = resources.getMarkerLibrary().findSymbol("首都");
			Symbol symbolLine = resources.getLineLibrary().findSymbol("国道(1)");
			Symbol symbolFill = resources.getFillLibrary().findSymbol("粉色1");
			// 点、线、填充符号面板
			panelSymbolPoint = new SmPanelSymbolPoint(symbolPoint, resources);
			panelSymbolLine = new SmPanelSymbolLine(symbolLine, resources);
			panelSymbolFill = new SmPanelSymbolFill(symbolFill, resources);
		} catch (NullPointerException e) {
			Application.getActiveApplication().getOutput().output("符号库中没有找到符号");
		}

	}

	private void initLayout() {
		JPanel jPanel = new JPanel();
		jPanel.add(panelSymbolPoint);
		jPanel.add(panelSymbolLine);
		jPanel.add(panelSymbolFill);
		this.add(jPanel);
	}
}
